# -*- coding:utf-8 -*-

from ronglian_sms_sdk import SmsSDK

from info.libs import constants


def send_message(tid, mobile, datas):
    sdk = SmsSDK(constants.RONGLIANYUN_ACCOUNT_SID,
                 constants.RONGLIANYUN_ACCOUNT_TOKEN,
                 constants.RONGLIANYUN_APP_ID)
    result = sdk.sendMessage(tid, mobile, datas)
    try:
        result = eval(result)
    except Exception as e:
        pass
    if result.get("statusCode") == "000000":
        # 返回0 表示发送短信成功
        return True
    else:
        # 返回-1 表示发送失败
        return False


if __name__ == '__main__':
    # 注意： 测试的短信模板编号为1
    send_message(1, '15935972229', ('1234', 5))
